﻿using Newtonsoft.Json;

namespace QQMapSDK.Models
{
    public class DrivingRouteResult
    {
        [JsonProperty("routes")]
        public List<Route>? Routes { get; set; }
    }

    public class Route
    {
        #region Model
        [JsonProperty("mode")]
        public string? Mode { get; set; }  // e.g. "DRIVING"

        [JsonProperty("distance")]
        public double Distance { get; set; }  // 单位：米

        [JsonProperty("duration")]
        public double Duration { get; set; }  // 单位：分钟

        [JsonProperty("traffic_light_count")]
        public int TrafficLightCount { get; set; }

        [JsonProperty("toll")]
        public double Toll { get; set; }  // 单位：元

        [JsonProperty("restriction")]
        public Restriction? Restriction { get; set; }

        [JsonProperty("polyline")]
        public List<double>? Polyline { get; set; }  // 经纬度坐标序列 [lat1, lng1, lat2, lng2, ...]

        [JsonProperty("waypoints")]
        public List<Waypoint>? Waypoints { get; set; }

        [JsonProperty("steps")]
        public List<RouteStep>? Steps { get; set; }

        [JsonProperty("tags")]
        public List<string?>? Tags { get; set; }  // 根据JSON示例，实际可能是空数组

        [JsonProperty("taxi_fare")]
        public TaxiFare? TaxiFare { get; set; }
        #endregion
    }

    public class Restriction
    {
        [JsonProperty("status")]
        public int Status { get; set; }  // 0-无限制, 1-有限制
    }

    public class Waypoint
    {
        #region Model
        [JsonProperty("id")]
        public string? Id { get; set; }

        [JsonProperty("title")]
        public string? Title { get; set; }

        [JsonProperty("location")]
        public Location Location { get; set; }

        [JsonProperty("polyline_idx")]
        public int PolylineIdx { get; set; }  // 在总polyline中的索引位置

        [JsonProperty("distance")]
        public double Distance { get; set; }  // 从起点到该点的距离（米）

        [JsonProperty("duration")]
        public double Duration { get; set; }  // 从起点到该点的时间（分钟）
        #endregion
    }

    public class RouteStep
    {
        #region Model
        [JsonProperty("instruction")]
        public string? Instruction { get; set; }  // 导航指令

        [JsonProperty("polyline_idx")]
        public List<int> PolylineIdx { get; set; }  // 该步骤在总polyline中的起止索引 [start, end]

        [JsonProperty("road_name")]
        public string? RoadName { get; set; }  // 道路名称

        [JsonProperty("dir_desc")]
        public string? Direction { get; set; }  // 方向描述（东/南/西/北）

        [JsonProperty("distance")]
        public double Distance { get; set; }  // 该步骤距离（米）

        [JsonProperty("act_desc")]
        public string? ActionDescription { get; set; }  // 动作描述（左转/右转等）

        [JsonProperty("accessorial_desc")]
        public string? AccessorialDescription { get; set; }  // 附加描述
        #endregion
    }

    public class TaxiFare
    {
        [JsonProperty("fare")]
        public double Fare { get; set; }  // 出租车费用（单位：元）
    }
}
